package com.lanou.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.entity.PsyKnow;
import com.lanou.mapper.PsyKnowMapper;
import com.lanou.service.PsyKnowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName PsyKnowServiceImpl
 * @Description TODO
 * @Author lizhenjiang
 * @Date 2025年08月13日 19:25
 * @Version 1.0
 */
@Service
public class PsyKnowServiceImpl implements PsyKnowService {
    @Autowired
    private PsyKnowMapper psyKnowMapper;

    @Override
    public PsyKnow getPsyKnow(Integer id) {
        return psyKnowMapper.selectPsyKnowById(id);
    }

    @Override
    public PageInfo<PsyKnow> getPsyKnows(PsyKnow psyKnow, Integer pageNum, Integer pageSize) {
        if(pageNum==null&&pageSize==null){
            PageInfo<PsyKnow> pageInfo= new PageInfo<>(psyKnowMapper.selectCharityList(psyKnow));
            return pageInfo;
        }
        PageHelper.startPage(pageNum, pageSize);
        List<PsyKnow> psyKnows=psyKnowMapper.selectCharityList(psyKnow);
        PageInfo<PsyKnow> pageInfo=new PageInfo<>(psyKnows);
        return pageInfo;
    }
}
